-
Notifications
You must be signed in to change notification settings - Fork 1k
Update play mvc to use AdviceScope #13140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update play mvc to use AdviceScope #13140
Conversation
👍 cc @SylvainJuge |
equalTo(CODE_NAMESPACE, "play.api.mvc.ActionBuilder$$anon$2"), | ||
equalTo(CODE_FUNCTION, "apply")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion this is not useful. It points to framework code and is the same for all endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree with Lauri here, if the value is the same for all spans then it does not provide much value for the end-user as with it they can't guess which part of the application code is related to the span.
We will very likely have exactly the same kind of issues with Webflux or other reactive frameworks where the application code is provided through nested lambdas and can't be described with a dedicated class/method. For those cases, the "span identity" should be provided through other attributes for example HTTP verb, path or span name which allows the end-user to understand the link with application code.
If we capture this technical and implementation-specific information, do we have a way to make any good use of it ?
One example I could think of is if we attempt to correlate those attributes with another source of information like inferred spans or profiling, however for those the correlation would be implemented through trace and span ID rather than on those code-level attributes.
I think this example is really interesting from the perspective of semconv attributes clarification as there are at least two distinct use-cases for those attributes:
- provide more information about a span for the end-user: we may recommend to capture information that is related to the application code rather than framework/library details
- capture "technical information" in a structured way that could not be described otherwise: profiling, inferred spans, ...
...avaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionScope.java
Outdated
Show resolved
Hide resolved
…mentation into add-code-attributes-play-mvc
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...avaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/AdviceScope.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...avaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/AdviceScope.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some suggestions for a few potential code improvements, mostly to move more code into AdviceScope
and inline what is needed there.
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...avaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/AdviceScope.java
Outdated
Show resolved
Hide resolved
I'd suggest the advice conversion work to be done in a different PR since the main problem with this PR is that the added code attribute isn't useful. |
288ae9b
to
d3ab703
Compare
d3ab703
to
ed566b9
Compare
I ended up just switching this PR to focus on the advice conversion. If it would be cleaner to close this one and open a fresh one, I'm happy to do that. |
Good idea, the scope of this PR is limited to play-2.4, there is also play-2.6 instrumentation that needs to be migrated, but this can be done in a separate PR. |
...ent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/Play24Singletons.java
Outdated
Show resolved
Hide resolved
...avaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/AdviceScope.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can inline and simplify the closeScope
method.
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
...rc/main/java/io/opentelemetry/javaagent/instrumentation/play/v2_4/ActionInstrumentation.java
Outdated
Show resolved
Hide resolved
} | ||
scope.close(); | ||
|
||
actionScope.end(throwable, responseFuture, (Action<?>) thisAction, req); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
casting to (Action<?>)
is a bit weird. What if you changed @Advice.This Object thisAction
to @Advice.This Action<?> thisAction
, would that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, yea that seems to work, thanks
there is a failure in play 2.6 tests https://scans.gradle.com/s/36fci3go5n3se |
Context parentContext = currentContext(); | ||
if (!instrumenter().shouldStart(parentContext, null)) { | ||
return; | ||
public static class AdviceScope { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a failure in play 2.6 tests scans.gradle.com/s/36fci3go5n3se
Strangely I haven't been able to reproduce the test failure locally. I am still investigating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @laurit !
Related to #7345Related to #13031
Pivoting from doing a code attribute addition to instead just migrating to using AdviceScope since the resulting code attributes were not useful. If we can come up with some other solution for the code attributes I can do a followup.